package com.hugh.hdfs.api.countsort;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @Author: Hugh
 * @Date: 2020/9/18
 */
public class HomeWorkMapper extends Mapper<LongWritable, Text, IntWritable, NullWritable> {

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        //1 读取一行文本，转为字符串，切分
        final String str = value.toString();
        IntWritable intVal = new IntWritable();
        intVal.set(Integer.parseInt(str));
        context.write(intVal, NullWritable.get());
    }
}
